package com.wechat.servlet.FriendRequest;

import com.wechat.DAO.DaoImpl.FriendRequestDAOIpml;
import com.wechat.DAO.FriendRequestDAO;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class DeleteFriendRequestServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String RID = request.getParameter("RID");
        String SID = request.getParameter("SID");
        FriendRequestDAO friendRequestDAO = new FriendRequestDAOIpml();
        try {
            friendRequestDAO.delete(SID,RID);
            System.out.println("成功删除好友请求:"+SID+"发给"+RID+"的");
            response.getWriter().write("success");
        }catch (Exception e){
            e.printStackTrace();
            response.getWriter().write("fail");
            return;
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
